<template>
  <div v-show="flag">
    <div class="shopping-car" id="resourceCar" @click="handleClick()">
      <el-badge :value="count" class="item" :max="10">
        <p><span class="el-icon-shopping-cart-2"></span></p>
      </el-badge>
    </div>
    <CarList @e-count="setCount" />
    <Download />
  </div>
</template>
<script>
import Bus from "@/utils/bus.js";
export default {
  components: {
    CarList: () => import("./carList.vue"),
    Download: () => import("../resource/download.vue"),
  },
  data() {
    return {
      count: 0,
      flag: false,
    };
  },
  watch: {
    $route() {
      this.flag = this.$route.path !== "/index";
    },
  },
  mounted() {
    this.flag = this.$route.path !== "/index";
  },
  methods: {
    setCount(v) {
      this.count = v;
    },
    handleClick() {
      if (!this.$store.getters.userId) {
        this.loginTip();
        return;
      }
      Bus.$emit("showDialogCarList");
    },
  },
};
</script>
<style scoped lang="scss">
.shopping-car {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 56px;
  height: 50px;
  text-align: center;
  line-height: 56px;
  border-radius: 50%;
  padding-top: 6px;
  background: $mainColor;
  border: 1px solid #fff;
  span {
    color: #fff;
    font-size: 30px;
  }
}
</style>